import { ElMessage, ElMessageBox } from "element-plus"
import { h }                       from "vue"

export function AreYouSure(message){
    return new Promise((resolve) => {
        let random   = Math.floor(Math.random() * 10000).toString()
        let alarmTip = h("div", null, [
            message && h("div", { style: "background: #ecf3ee;padding:5px;color: gray;margin-bottom:5px" }, message),
            h("div", null, [
                h("span", null, "请输入:("),
                h("span", { style: "color: red" }, random),
                h("span", null, ")以继续"),
            ]),
        ])
        
        ElMessageBox.prompt(alarmTip, "键入继续...", {
            confirmButtonText: "继续",
            cancelButtonText : "取消",
        }).then(({ value }) => {
            if(value === random){
                resolve(random)
            }
            else{
                ElMessage.warning("输入错误")
            }
        }).catch(e => {
        })
    })
}
